Zooming and panning
Zooming and panning change the visible range of the axes: the user zooms with the mouse wheel or a pinch, and pans
by dragging the chart. Both features only move the MinLimit and MaxLimit of the axes, so the same range can also
be set from code, to show the data page by page or to drive the chart from a scroll bar. For axis limits in general,
see the axes article.
This article highlights the most used features. Every option is listed in the API explorer: ZoomAndPanMode, Axis and CartesianChartEngine.
Enable zooming
Zooming and panning are disabled by default. Set the ZoomMode property of the chart to enable them. With X, the
user zooms and pans only the X axis, and the Y axis fits the points that are visible in the current X range.
cartesianChart1.ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.X; // mark

using System;
using System.Windows.Forms;
using LiveChartsCore.SkiaSharpView.WinForms;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore;
namespace WinFormsSample.Lines.Zoom;
public partial class View : UserControl
{
public View()
{
InitializeComponent();
Size = new System.Drawing.Size(50, 50);
var values = Fetch();
var series = new ISeries[]
{
new LineSeries<int>
{
Values = values
}
};
var cartesianChart = new CartesianChart
{
Series = series,
ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.X, // mark
Location = new System.Drawing.Point(0, 0),
Size = new System.Drawing.Size(50, 50),
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
};
Controls.Add(cartesianChart);
}
private static int[] Fetch()
{
var values = new int[100];
var r = new Random();
var t = 0;
for (var i = 0; i < 100; i++)
{
t += r.Next(-90, 100);
values[i] = t;
}
return values;
}
}
To change the default of every chart in the application, call
LiveCharts.Configure(config => config.WithZoomMode(ZoomAndPanMode.X)) when the application starts, before any chart
is created.
Zoom modes
ZoomMode is a ZoomAndPanMode flag
enum, so the options can be combined:
None: zooming and panning are disabled, the default.PanXandPanY: the user can pan the X or the Y axis.ZoomXandZoomY: the user can zoom the X or the Y axis, with the wheel, a pinch or a section.X: zoom and pan on the X axis, the same asPanX | ZoomX.Y: zoom and pan on the Y axis, the same asPanY | ZoomY.Both: zoom and pan on both axes, the same asX | Y.NoFit: lets the user move past the data, see fit to data.NoZoomBySection: disables the zoom by section.InvertPanningPointerTrigger: swaps the triggers of panning and zoom by section, see mouse and touch.
The last three flags only change the behaviour of the zoom and pan flags they are combined with.
Each gesture has its own flag, so they can be mixed: ZoomAndPanMode.ZoomX | ZoomAndPanMode.PanY zooms the X axis and
pans the Y axis, and ZoomAndPanMode.ZoomX zooms the X axis with no panning at all. Panning closes the tooltip while
the pointer drags, so a zoom-only mode keeps tooltips working when the user drags a finger over the chart on a touch
screen.
myChart.ZoomMode = ZoomAndPanMode.Both | ZoomAndPanMode.NoFit; // mark
With Y the user moves only the Y axis, and the X axis fits the points visible in the current Y range. With Both
the user moves both axes; it is easy to get lost in the data, so consider a button that
clears the zoom.

Mouse and touch
| Action | Mouse | Touch |
|---|---|---|
| Zoom | Mouse wheel | Pinch |
| Pan | Press the left button and drag | Press and drag |
| Zoom by section | Press the right button and drag | Double tap, keep the finger down on the second tap, drag |
The wheel zooms around the pointer: the value under the pointer stays in place.
This control does not handle the pinch gesture, use the mouse wheel to zoom.
When ZoomMode has the InvertPanningPointerTrigger flag, the triggers swap: the right button (or a double tap) pans,
and the left button (or a single tap) starts a zoom by section.
Zoom by section
The user can draw a rectangle over the chart and zoom to it. The feature is enabled with zooming, add the
NoZoomBySection flag to disable it. The section must start inside the plot area, and a drag shorter than 15 pixels
is ignored. When only one axis zooms, the rectangle covers the full height (or width) of the plot area, and only that
axis changes. The rectangle is drawn with a semi-transparent blue fill.

Zooming speed
ZoomingSpeed sets how much each step of the mouse wheel zooms, from 0 (slowest) to 1 (fastest). It is not the
speed of the animations. Each step in makes the visible range 1 - ZoomingSpeed times its length, each step out
divides the length by the same amount. The default is 0.2, so each step in shows 80% of the previous range. Values
under 0.1 work as 0.1 and values over 0.95 work as 0.95. The pinch gesture does not use this property.
cartesianChart1.ZoomingSpeed = 0.1; // mark
LiveCharts.Configure(config => config.WithZoomSpeed(0.1)) changes the default for every chart.
Fit to data
By default the chart keeps the data in view:
- Zooming out stops at the bounds of the data.
- Panning can go past the first or last point by the axis
BouncingDistance, a fraction of the plot area width (X axes) or height (Y axes). The default is0.25, a quarter of the plot area. When the pointer is released, the axis goes back to the data. SetBouncingDistanceto0to stop panning at the data.
Add the NoFit flag to let the user zoom and pan freely, past the data:

Minimum zoom
The axis MinZoomDelta property limits how deep the user can zoom: it is the smallest visible range the zoom can
reach, in data units (MaxLimit - MinLimit). Zooming in stops there, with the wheel, a pinch or a section. When it is
null, the default, the chart uses three times the smallest distance between two consecutive points of the data.
XAxes = new[]
{
new Axis
{
MinZoomDelta = 5 // the visible range is never shorter than 5 units // mark
}
};
Clearing the zoom
Set MinLimit and MaxLimit back to null (or double.NaN) to clear the zoom and fit the data to the chart again:
// where myChart is a reference to the chart in the UI
foreach (var x in myChart.XAxes)
{
x.MinLimit = null;
x.MaxLimit = null;
}
foreach (var y in myChart.YAxes)
{
y.MinLimit = null;
y.MaxLimit = null;
}
Reading the visible range
While the user zooms or pans, the chart sets the MinLimit and MaxLimit of the axes. The Axis class implements
INotifyPropertyChanged, so the PropertyChanged event tells when the visible range changes, by the user or by code:
// where myChart is a reference to the chart in the UI
myChart.XAxes.First().PropertyChanged += OnAxisPropertyChanged;
// ...
private void OnAxisPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is not (nameof(Axis.MinLimit) or nameof(Axis.MaxLimit))) return;
var axis = (ICartesianAxis)sender!;
Trace.WriteLine($"{axis.Orientation} visible range: {axis.MinLimit} - {axis.MaxLimit}");
}
Paging
To show the data a page at a time, set MinLimit and MaxLimit from code. In this sample, the buttons move the X
axis by pages of eleven columns, and "Clear" shows all the data again. Each column is centered on its index, so
-0.5 to 10.5 shows the columns 0 to 10 completely. ZoomMode is X, so the user can still zoom and pan from
any page.

using System;
using System.Windows.Forms;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.WinForms;
using SkiaSharp;
#pragma warning disable IDE1006 // Naming Styles
namespace WinFormsSample.Axes.Paging;
public partial class View : UserControl
{
private readonly CartesianChart cartesianChart;
private readonly Axis xAxis;
private readonly int[] values;
public View()
{
InitializeComponent();
Size = new System.Drawing.Size(100, 100);
values = Fetch();
xAxis = new Axis();
var series = new ISeries[]
{
new ColumnSeries<int> { Values = values }
};
cartesianChart = new CartesianChart
{
Series = series,
XAxes = [xAxis],
ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.X,
Location = new System.Drawing.Point(0, 50),
Size = new System.Drawing.Size(100, 50),
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
};
Controls.Add(cartesianChart);
var panel = new FlowLayoutPanel { Dock = DockStyle.Top, Height = 50 };
var btn1 = new Button { Text = "Page 1" };
var btn2 = new Button { Text = "Page 2" };
var btn3 = new Button { Text = "Page 3" };
var btnClear = new Button { Text = "Clear" };
btn1.Click += (s, e) => GoToPage(0);
btn2.Click += (s, e) => GoToPage(1);
btn3.Click += (s, e) => GoToPage(2);
btnClear.Click += (s, e) => SeeAll();
panel.Controls.AddRange([btn1, btn2, btn3, btnClear]);
Controls.Add(panel);
}
private void GoToPage(int page)
{
if (page == 0) { xAxis.MinLimit = -0.5; xAxis.MaxLimit = 10.5; }
else if (page == 1) { xAxis.MinLimit = 9.5; xAxis.MaxLimit = 20.5; }
else if (page == 2) { xAxis.MinLimit = 19.5; xAxis.MaxLimit = 30.5; }
}
private void SeeAll()
{
xAxis.MinLimit = null;
xAxis.MaxLimit = null;
}
private static int[] Fetch()
{
var random = new Random();
var trend = 100;
var values = new System.Collections.Generic.List<int>();
for (var i = 0; i < 100; i++)
{
trend += random.Next(-30, 50);
values.Add(trend);
}
return [.. values];
}
}
Scrollable chart
A second, smaller chart can work as a scroll bar. In this sample the main chart has ZoomMode set to X. Below it,
a chart 100 pixels tall plots the same data with hidden axes and no tooltips, and a RectangularSection marks the
range visible in the main chart. Both charts set the same left and right DrawMargin, so their plot areas line up.
The sync goes both ways:
- When the main chart updates (after a zoom or a pan), its
UpdateStartedevent copies the X axis limits to theXiandXjof the section. - While the pointer is pressed on the small chart, each move converts the pointer position to data coordinates with
ScalePixelsToData, centers the section there keeping its width, and sets the same range as theMinLimitandMaxLimitof the main chart's X axis.

using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Forms;
using LiveChartsCore.Defaults;
using LiveChartsCore.Kernel.Sketches;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Drawing;
using LiveChartsCore.SkiaSharpView.Painting;
using LiveChartsCore.SkiaSharpView.WinForms;
using SkiaSharp;
namespace WinFormsSample.General.Scrollable;
public partial class View : UserControl
{
private readonly CartesianChart _mainChart;
private readonly CartesianChart _scrollBarChart;
private bool _isDown = false;
private readonly ObservableCollection<ObservablePoint> _values = [];
public View()
{
InitializeComponent();
Size = new System.Drawing.Size(50, 50);
var trend = 1000;
var r = new Random();
for (var i = 0; i < 500; i++)
_values.Add(new ObservablePoint(i, trend += r.Next(-20, 20)));
var auto = LiveChartsCore.Measure.Margin.Auto;
_mainChart = new CartesianChart
{
Series = [
new LineSeries<ObservablePoint>
{
Values = _values,
GeometryStroke = null,
GeometryFill = null,
DataPadding = new(0, 1)
}
],
XAxes = [new Axis()],
ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.X,
// force the left margin to be 100 and the right margin 50 in both charts, this will
// align the start and end point of the "draw margin",
// no matter the size of the labels in the Y axis of both chart.
DrawMargin = new(100, auto, 50, auto),
// out of livecharts properties...
Location = new System.Drawing.Point(0, 0),
Size = new System.Drawing.Size(50, 50),
Dock = DockStyle.Fill
};
_mainChart.UpdateStarted += OnChart_Updated;
_scrollBarChart = new CartesianChart
{
Series = [
new LineSeries<ObservablePoint>
{
Values = _values,
GeometryStroke = null,
GeometryFill = null,
DataPadding = new(0, 1)
}],
DrawMargin = new(100, auto, 50, auto),
Sections = [
new RectangularSection
{
Fill = new SolidColorPaint(new SKColor(255, 205, 210, 100))
}
],
XAxes = [new Axis { IsVisible = false }],
YAxes = [new Axis { IsVisible = false }],
TooltipPosition = LiveChartsCore.Measure.TooltipPosition.Hidden,
// out of livecharts properties...
Location = new System.Drawing.Point(0, 0),
Size = new System.Drawing.Size(50, 50),
Dock = DockStyle.Fill
};
_scrollBarChart.MouseDown += CartesianChart2_MouseDown;
_scrollBarChart.GetDrawnControl().MouseMove += CartesianChart2_MouseMove;
_scrollBarChart.MouseUp += CartesianChart2_MouseUp;
var splitContainer = new SplitContainer
{
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
//IsSplitterFixed = true,
Orientation = Orientation.Horizontal
};
splitContainer.Panel1.Controls.Add(_mainChart);
splitContainer.Panel2.Controls.Add(_scrollBarChart);
Controls.Add(splitContainer);
}
private void OnChart_Updated(IChartView chart)
{
var cartesianChart = (CartesianChart)chart;
var x = cartesianChart.XAxes.First();
// update the scroll bar thumb when the chart is updated (zoom/pan)
// this will let the user know the current visible range
var thumb = (RectangularSection)_scrollBarChart.Sections.First();
thumb.Xi = x.MinLimit;
thumb.Xj = x.MaxLimit;
}
private void CartesianChart2_MouseDown(object sender, MouseEventArgs e) =>
_isDown = true;
private void CartesianChart2_MouseUp(object sender, MouseEventArgs e) =>
_isDown = false;
private void CartesianChart2_MouseMove(object sender, MouseEventArgs e)
{
if (!_isDown) return;
var scrollBarChart = _scrollBarChart;
var positionInData = scrollBarChart.ScalePixelsToData(new(e.Location.X, e.Location.Y));
var thumb = (RectangularSection)_scrollBarChart.Sections.First();
var currentRange = thumb.Xj - thumb.Xi;
// update the scroll bar thumb when the user is dragging the chart
thumb.Xi = positionInData.X - currentRange / 2;
thumb.Xj = positionInData.X + currentRange / 2;
// update the chart visible range
_mainChart.XAxes.First().MinLimit = thumb.Xi;
_mainChart.XAxes.First().MaxLimit = thumb.Xj;
}
}
Zoom and pan from code
The chart engine has the methods that the gestures call. They take the flags to apply, so they work even when
ZoomMode is None, for example to zoom with buttons or with your own gestures. Positions and distances are in pixels.
// where myChart is a reference to the chart in the UI
var engine = (CartesianChartEngine)myChart.CoreChart;
// zooms in on the X axis, keeping the value at the pixel (100, 100) in place
engine.Zoom(ZoomAndPanMode.X, new(100, 100), ZoomDirection.ZoomIn);
// pans both axes by 10 pixels
engine.Pan(ZoomAndPanMode.Both, new(10, 10));
// zoom by section: starts the rectangle at (100, 100),
engine.StartZoomingSection(ZoomAndPanMode.Both, new(100, 100));
// grows the drawn rectangle to (150, 150), the zoom is not applied yet,
engine.GrowZoomingSection(ZoomAndPanMode.Both, new(150, 150));
// and zooms to the rectangle that ends at (200, 200)
engine.EndZoomingSection(ZoomAndPanMode.Both, new(200, 200));
Zoom honours the NoFit flag it receives: without it, the zoom is fitted to the data, as the wheel does.